
package com.idealighter.game.games.texaspoker.handler;

import com.idealighter.game.core.annotation.ResMsgHandler;
import com.idealighter.game.gamehall.dto.SeatInfo;
import com.idealighter.game.games.texaspoker.TexaspokerPlayer;
import com.idealighter.game.games.texaspoker.message.ReqNextStepMsg;
import com.idealighter.game.games.texaspoker.message.ResBetMsg;
import com.idealighter.game.message.core.ResMessage;
import com.idealighter.game.robot.core.Player;
import com.idealighter.game.robot.handler.ResMessageHandler;

import java.util.concurrent.TimeUnit;


@ResMsgHandler(505219)
public class ResBetHandler implements ResMessageHandler {

  // private static final Logger LOG = LoggerFactory.getLogger(ResBetHandler.class);

  @Override
  public void action(Player player, ResMessage message) {
    ResBetMsg msg = (ResBetMsg) message;
    TexaspokerPlayer texaspokerPlayer = (TexaspokerPlayer) player;
    SeatInfo seatInfo = player.seat(player.playerId);
    if (seatInfo != null && seatInfo.getOrder() == msg.getOrder()) {
      texaspokerPlayer.curBet += msg.getBet();
      // player.sendMsg(new ReqNextStepMsg());
      player.schedule(() -> player.sendMsg(new ReqNextStepMsg()), 1, TimeUnit.SECONDS);
    }
  }
}
